package org.gd.hellojaxb.example.interfaces;

import org.gd.hellojaxb.utils.Marshall;
import org.gd.hellojaxb.utils.MarshallProperties;
import org.gd.hellojaxb.utils.UnMarshall;

public class UserMain {

    public static void main(String...args) {
        try {
            XmlListUser users = new XmlListUser();
            users.add(new XmlUser("name1", "phone1"));
            users.add(new XmlUser("name2", "phone2"));
            users.add(new XmlUser("name3", "phone3"));

            String str = Marshall.getInstance().marshal(users,
                            MarshallProperties.FORMATTED_OUTPUT,
                            MarshallProperties.WITHOUT_XML_HEADER);
            System.out.println(str);
            users = UnMarshall.unmarshal(str, XmlListUser.class);

            System.out.println();
            System.out.println(users.getStr().get(0));
            System.out.println(users.getStr().get(1));
            System.out.println(users.getStr().get(2));
        } catch (Throwable e) {
            e.printStackTrace(System.err);
        } finally {
            System.exit(0);
        }
    }
}
